package model

import (
	"fmt"
	_ "github.com/go-sql-driver/mysql"
	"github.com/jinzhu/gorm"
	"picupload/config"
)

var DB *gorm.DB

func init() {
	var err error
	DB, err = gorm.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8&parseTime=True&loc=Local", config.DB_USER, config.DB_PWD, config.DB_HOST, config.DB_NAME))
	if err != nil {
		fmt.Println(err.Error())
	}
	DB.SingularTable(true)
	DB.LogMode(true)
	fmt.Println("mysql connection success")
}
